import * as PIXI from 'pixi.js'
import { useWindowSize } from '@vueuse/core'
import useMainStore from '@/store/modules/useMainStore'
import { closeDiyModal } from '@/utils/events'

export default async () => {
  const { width } = useWindowSize()
  const mainStore = useMainStore()
  const { scale } = mainStore.getAppAttr
  const bundle = await PIXI.Assets.loadBundle('module')
  const sprite = new PIXI.Sprite(
    new PIXI.Texture({
      source: new PIXI.Texture(bundle.close).source,
    }),
  )
  sprite.anchor.set(0.5)
  sprite.scale.set(0.8)
  sprite.position.set(width.value / scale - sprite.width * 0.8, sprite.height * 0.8)
  closeDiyModal.whiteAdd(sprite)
  return sprite
}
